package com.example.travel.config;

/**
 * @Author : LinQingLiang
 * @file : InterceptorConfig.java
 * @Since : 2023/1/13 16:16
 */

import com.example.travel.interceptor.AuthInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor())
                .addPathPatterns("/**") //拦截所有请求
                .excludePathPatterns("/user/login","/user/register","/**/import","/**/export","/file/**","/alipay/**","/swagger-resources/**", "/*/api-docs");
    }

    @Bean
    public AuthInterceptor authInterceptor(){
        return new AuthInterceptor();
    }
}
